<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * DESCRIPTION:
 *  base class for all form fields
 * FIELDS:
 *  protected $name is the name parameter
 *  protected $type is the type parameter
 *  protected $caption is the caption of field (at the left)
 *  protected $value is the default value of field
 *  protected $is_required marks that field is required (makes caption bold)
 *  protected $params is additional tag parameters
 *  protected $help is the help text
 *  protected $help_url used when  we need to link to help page
 *  protected $class is the class parameter
 *  protected $style is the style parameter
 * METHODS:
 *  void __construct($name, $type, $caption, $is_required = false, $value = "", $parameters = "", $help = "", $help_url = "") is a class constructor
 *  abstract check() validates the field
 *  abstract get_html() returns html code of field
 *  public mixed __get($key) is std get accessor
 *  protected string encodestring($st) transliterates cyrrilic to latin
 * ======
 * @author at8eqeq3
 * @version 0.1
 * @uses utils/strconv.php
 */
abstract class field {
    protected $name;
    protected $type;
    protected $caption;
    protected $value;
    protected $is_required;
    protected $params;
    protected $help;
    protected $help_url;
    protected $class;
    protected $style;

    function __construct($name, $type, $caption, $is_required = false, $value = "", $params = "", $help = "", $help_url = ""){
        $this->name = transliterate($name);
        $this->type = $type;
        $this->caption = $caption;
        $this->value = $value;
        $this->is_required = $is_required;
        $this->params = $params;
        $this->help = $help;
        $this->help_url = $help_url;
    }

    //abstract function check();

    //abstract function get_html();

    public function __get($key){
        if(isset($this->$key)){
            return $this->$key;
        }else{
            throw new ExceptionMember($key, 'There is no '.__CLASS__.'::'.$key.' member');
        }
    }
}
?>